/*
 * portlet widget
 */
Qlsolution.widgets.portlet = {

	/*
	 * set dragable columns
	 */
	setDragable: function(settings){
		$(settings.selector).sortable({
			placeholder: settings.placeholder,
			handle: '.elementHeader',
			connectWith: settings.connectWith
		});
	},

	/*
	 * set column width
	 */
	setColumnWidth: function(settings){
		if(settings.columnWidth != undefined){
			var widthArray = settings.columnWidth.split(' ');
			$(settings.selector).each(function(key, val){
				$(this).css('width', widthArray[key]);
			});
		}
	},

	/*
	 * handle header icons
	 */
	handleHeaderIcons: function(settings){
		$(settings.selectorElement + ' .elementHeader .icons .arrow').click(function(){
			if($(this).hasClass('arrowUp')){
				$(this).parent().parent().parent().find('.elementContent').slideUp();
				$(this).removeClass('arrowUp').addClass('arrowDown');
				$(this).parent().parent().addClass('brb7');
			}
			else{
				$(this).parent().parent().parent().find('.elementContent').slideDown();
				$(this).removeClass('arrowDown').addClass('arrowUp');
				$(this).parent().parent().removeClass('brb7');
			}
		});
	},

	start: function(settings){
		Qlsolution.widgets.portlet.setDragable(settings);
		Qlsolution.widgets.portlet.setColumnWidth(settings);
		Qlsolution.widgets.portlet.handleHeaderIcons(settings);
	}

};